package com.shanghaionstar.user.service;

import android.content.Context;

import com.onstar.cn.api.PublicService;
import com.onstar.cn.common.util.Constants;
import com.onstar.cn.common.util.DeviceUtil;
import com.onstar.cn.framework.annotation.http.HeadsValue;
import com.onstar.cn.framework.annotation.http.Request;
import com.onstar.cn.framework.mvp.base.core.BaseService;
import com.onstar.cn.framework.network.HttpInjectUtils;
import com.onstar.cn.framework.network.entity.RequestEntity;
import com.onstar.cn.framework.network.enumtype.HttpAccept;
import com.onstar.cn.framework.network.enumtype.HttpMethod;
import com.onstar.cn.framework.network.enumtype.Language;
import com.onstar.cn.framework.utils.GsonHelper;
import com.onstar.cn.mag.enumtype.CategoryType;
import com.onstar.cn.more.response.GetHelpListResponseType;
import com.shanghaionstar.utils.BusinessUtil;
import com.shanghaionstar.utils.NetConnectUtil;

/**
 * Created by 7828wc on 16/7/1.
 */
public class HelpService extends BaseService<GetHelpListResponseType> {
    private Context context;

    public HelpService(Context context) {
        this.context = context;
    }

    @Override
    @Request(heads = @HeadsValue(accept = HttpAccept.JSON, language = Language.AUTO), method = HttpMethod.GET)
    public RequestEntity getRequestEntity() {
        RequestEntity requestEntity = NetConnectUtil.getAuthRequestEntity(context);
        PublicService publicService = new PublicService(Constants.CURRENT_SERVER_URL);
        requestEntity = publicService.queryHelpList(requestEntity, CategoryType.ONSTAR_SYBZ.value(), new DeviceUtil(context).getAppVersionCode() + "");
//        String method = Thread.currentThread().getStackTrace()[1].getMethodName();
        requestEntity = HttpInjectUtils.injectHttp(getClass(), "getRequestEntity", requestEntity);
        return requestEntity;
    }



    @Override
    public GetHelpListResponseType jsonToBean(String json) {
        return GsonHelper.fromJson(json,GetHelpListResponseType.class);
    }
}
